// details.js
const app = getApp();
const { pois } = require('../../utils/data.js');
const { getPoiTypeName, filterPoiByType } = require('../../utils/util.js');

Page({
  data: {
    attractions: [],
    restaurants: [],
    hotels: []
  },

  onLoad: function () {
    // 按类型分组POI
    this.setData({
      attractions: filterPoiByType(pois, 'attraction'),
      restaurants: filterPoiByType(pois, 'restaurant'),
      hotels: filterPoiByType(pois, 'hotel')
    });
  },

  // 查看POI详情
  viewPoiDetail: function(e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/details/poi-detail?id=${id}`
    });
  },

  // 导航到POI
  navigateToPoi: function(e) {
    const id = e.currentTarget.dataset.id;
    const poi = pois.find(p => p.id === id);
    
    if (poi) {
      wx.openLocation({
        latitude: poi.position[1],
        longitude: poi.position[0],
        name: poi.name,
        address: poi.address || '',
        scale: 18
      });
    }
  }
}) 